package com.iss.yunpan.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iss.yunpan.entity.FileContent;
import com.iss.yunpan.service.HuiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;



import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class HuiController {

@Autowired
    private HuiService service;

    @GetMapping("deleteAllFile")
    public String deleteAllFile(){
        return "file/huiList";
    }


    @RequestMapping("deleteAllFile")
    @ResponseBody
    public Map<String,Object> deleteAllFile(String id,int page,int limit,String parentId) {  //修改？
        System.out.println(id);
        if(parentId==null) {
            parentId = "0";
        }
        Map<String, Object> map = new HashMap<>();
        PageHelper.startPage(page,limit);
        List<FileContent> list = service.deleteAllFile(id);
        PageInfo<FileContent> pageInfo = new PageInfo<FileContent>(list);
        map.put("code",0);
        map.put("msg","");
        map.put("count",pageInfo.getTotal());//获取总个数
        map.put("data", pageInfo.getList());//获取数据
        return map;
    }

}

